<template>
  <div class="member-group-tab" :style="sectionStyle" @click.stop="handleClassifyTabItem('userMemberTabControl')">
    <div class="group-tab-content" :style="sectionBorderRadius">
      <div
        class="group-item"
        :class="[
          index + 1 == memberTabGroup.length ? 'no-affter' : '',
          memberTabNum == 2 ? 'two-node' : '',
          memberTabNum == 1 ? 'one-node' : '',
        ]"
        v-for="(item, index) in memberTabGroup"
        :key="index"
      >
        <section class="group-box">
          <div class="item-hover">
            <div
              class="edit-box"
              @click.stop="handleTabItem('userMemberTabItemControl', item)"
            >
              <i class="iconfont icon-mokuai-bianji"></i>
            </div>
          </div>
          <div class="group-item-title">
            <img :src="item.picImg || defaultImg" alt="" />
            <p :style="{ color: item.titleColor }">{{ item.title }}</p>
          </div>
          <p class="subtitle">
            <span :style="{ color: item.subtitleColor }">{{
              item.subtitle
            }}</span>
            <i
              :style="{ color: item.subtitleColor }"
              class="iconfont icon-weibiaoti-13"
            ></i>
          </p>
        </section>
      </div>
      <div class="member-group-bg" :style="memberGroupBg"></div>
      <div class="member-group-hover">
        <div
          class="edit-box"
          @click="handleClassifyTabItem('userMemberTabControl')"
        >
          <i class="iconfont icon-mokuai-bianji"></i>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import defaultImg from "@/assets/images/diy/default_img.png";

export default {
  name: "userMember",
  props: {
    propsData: {
      type: Object,
      default: {},
    },
  },
  components: {},
  data() {
    return {
      defaultImg,
    };
  },
  mounted() {},
  watch: {},
  computed: {
    memberTabGroup() {
      return this.propsData.params.memberTabGroup;
    },
    memberGroupBg() {
      let style = Object.assign({}, this.propsData.params.memberTabCss);
      delete style.padding;
      return style;
    },
    memberTabNum() {
      return this.propsData.params.memberTabNum;
    },
    sectionStyle() {
      let style = this.propsData.params.memberTabCss;
      let obj = {
        margin: `0 ${style.padding}px`,
      };
      return obj;
    },
    sectionBorderRadius() {
      let style = this.propsData.params.memberTabCss;
      let obj = {
        borderRadius: `${style.borderRadius}px`,
      };
      return obj;
    },
  },
  methods: {
    // 点击编辑当前状态
    handleClassifyTabItem(name) {
      console.log("卡萨丁", name);
      let data = Object.assign({}, this.propsData);
      data.controlComName = name;
      this.$emit("handleItemToControl", data);
    },
    handleTabItem(name, item) {
      let data = item;
      data.controlComName = name;
      this.$emit("handleItemToControl", data);
    },
  },
};
</script>

<style lang="scss" scoped>
.member-group-tab {
  height: 47px;
  position: relative;
  margin: 0 auto;
  .group-tab-content {
    width: 100%;
    height: 55px;
    position: absolute;
    left: 0;
    bottom: 0;
    z-index: 11;
    border-radius: 10px;
    overflow: hidden;
    display: flex;
    align-items: center;
    .group-item {
      width: 33.3%;
      height: 100%;
      display: flex;
      align-items: center;
      padding-left: 12px;
      position: relative;
      z-index: 15;
      .group-box {
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: flex-start;
        position: relative;
        .item-hover {
          width: 100%;
          height: 100%;
          border: 1px solid #1890fc;
          position: absolute;
          left: 0;
          top: 0;
          display: none;
          .edit-box {
            width: 20px;
            height: 20px;
            background: #1890fc;
            border-radius: 0px 0px 0px 4px;
            display: flex;
            justify-content: center;
            align-items: center;
            cursor: pointer;
            position: absolute;
            right: 0;
            top: 0;
            .iconfont {
              font-size: 18px;
              color: #ffffff;
            }
          }
        }
      }
      .group-box:hover > .item-hover {
        display: block;
      }
      .group-item-title {
        display: flex;
        align-items: center;
        img {
          width: 14px;
          height: 14px;
          //   background: #303685;
          border-radius: 50%;
          display: block;
          margin-right: 2px;
        }
        p {
          margin-bottom: 0;
          font-size: 13px;
          font-family: PingFang SC;
          font-weight: 600;
          color: #262626;
        }
      }
      .subtitle {
        font-size: 11px;
        font-family: PingFang SC;
        font-weight: 400;
        color: #b4853f;
        margin-bottom: 0;
        margin-top: 3px;
        display: flex;
        align-items: center;
        .iconfont {
          font-size: 12px;
          color: #b4853f;
          transform: scale(0.8);
          display: block;
        }
      }
    }
    .group-item::after {
      content: "";
      width: 1px;
      height: 20px;
      background: #efd5b1;
      position: absolute;
      right: 0;
      top: 17.5px;
    }
    .no-affter::after {
      display: none;
    }
    .member-group-bg {
      width: 100%;
      height: 100%;
      z-index: -1;
      position: absolute;
      left: 0;
      top: 0;
    }
    .two-node {
      width: 50%;
    }
    .one-node {
      width: 100%;
    }
    .member-group-hover {
      width: 100%;
      height: 100%;
      border: 1px solid #1890fc;
      position: absolute;
      left: 0;
      top: 0;
      z-index: 11;
      display: none;
      .edit-box {
        width: 20px;
        height: 20px;
        background: #1890fc;
        border-radius: 0px 0px 0px 4px;
        display: flex;
        justify-content: center;
        align-items: center;
        cursor: pointer;
        position: absolute;
        right: 0;
        top: 0;
        z-index: 110;
        .iconfont {
          font-size: 18px;
          color: #ffffff;
          cursor: pointer;
        }
      }
    }
  }
  .group-tab-content:hover > .member-group-hover {
    display: block;
  }
}
</style>
